package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.CaiLiaoZhiLiangBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_cailiao_zhiliang_item.view.*

/**
 * Created by Administrator on 2018/5/14/014.
 * 作者：刘洋
 */
class CaiLiaoZhiLiangKAdapter(var context: Context, var list: MutableList<CaiLiaoZhiLiangBean>) : BaseAdapter(){
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.lv_cailiao_zhiliang_item,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        val it =list[position]
        Myutil.settv(it.gi_name,h.TvBianma)
        Myutil.settv(it.iu_name,h.TvGongYingShang)
        Myutil.settv(it.mc2_name,h.TvCailiaoLeibie)
        Myutil.settv(it.qi_name,h.TvWentiDaima)
        Myutil.settv(Myutil.getdata(it.jianyan_time),h.TvJianyanTime)
        Myutil.settv(it.cailiao_shuliang,h.TvCailiaoShuliang)
        Myutil.settv(it.choucha_shuliang,h.TvChouchaShuliang)
        Myutil.settv(it.hege_shuliang,h.TvHegeShuliang)
        Myutil.settv(it.quality_decision,h.TvZhiliangPanding)
        Myutil.settv(it.process_mode,h.TvChuLi)
        Myutil.settv(it.solution,h.TvCaigouJiejue)
        return v
    }

    override fun getItem(position: Int): Any = list[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getCount(): Int = list.size
    class Header(var v : View){
        val TvBianma=v.TvBianma
        val TvGongYingShang=v.TvGongYingShang
        val TvCailiaoLeibie=v.TvCailiaoLeibie
        val TvWentiDaima=v.TvWentiDaima
        val TvJianyanTime=v.TvJianyanTime
        val TvCailiaoShuliang=v.TvCailiaoShuliang
        val TvChouchaShuliang=v.TvChouchaShuliang
        val TvHegeShuliang=v.TvHegeShuliang
        val TvZhiliangPanding=v.TvZhiliangPanding
        val TvChuLi=v.TvChuLi
        val TvCaigouJiejue=v.TvCaigouJiejue
    }
}